int romanToInt(char* s) {
    int Values[1000];
    Values['I'] = 1;
    Values['V'] = 5;
    Values['X'] = 10;
    Values['L'] = 50;
    Values['C'] = 100;
    Values['D'] = 500;
    Values['M'] = 1000;
    int ans = 0;
    int n = strlen(s);
    for (int i = 0; i < n; ++i) {
        int value = Values[s[i]];
        if (i < n - 1 && value < Values[s[i + 1]]) {
            ans -= value;
        }
        else {
            ans += value;
        }
    }
    return ans;
}